package com.diy.sigmund.diycommon.test.spring.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @author ylm-sigmund
 * @since 2021/12/7 10:55
 */
@Order(9999)
// @Component
@Aspect
public class PointcutMethodAspect {

    private static final Logger log = LoggerFactory.getLogger(PointcutMethodAspect.class);

    // 切所有方法
    // @Pointcut("execution(public * com.diy.sigmund.diycommon.test.entity.TestAspect.*(..))")
    @Pointcut("execution(public * com.diy.sigmund.diycommon.test.entity.TestAspectImpl.run(..))")
    public void pointcut() {
    }

    @Around("pointcut()")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        log.info(pjp.getSignature().getName());
        Object resultMsg = pjp.proceed();
        log.info("我进入了切面");
        return resultMsg;
    }
}
